﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T15OOP2
{
    class Action : ICart
    {
        private ArrayList products = new ArrayList();

        public void Buy(Product p)
        {
            Console.WriteLine("购买{0}",p.Name );
            Add(p);
        }

        public bool Add(Product p)
        {
            products.Add( p);
            return true;
        }

        public void Show()
        {
            foreach (Product  p in products )
            {
                if(p is Book )//调用下转型Book独有的方法
                {
                    Console.WriteLine((p as Book).Isbn);  
                }
                p.Show();//运行时多态
                p.ShowDetail();
            }
        }

        public object Find(int index)
        {
            throw new NotImplementedException();
        }

        public bool Remove(int index)
        {
            throw new NotImplementedException();
        }

       
        public bool Update(int index)
        {
            throw new NotImplementedException();
        }
    }
}
